--Randomizes the controller of each unit 1 minute into the game

function gadget:GetInfo()
	return {
		name	= "Conflict Terra Team Randomizer",
		desc	= "Randomly assigns units to teams",
		author	= "Max and Roy",
		date	= "today",
		license	= "None, just testing for fun",
		layer = 0,
		enabled	= false
	}
end

if not gadgetHandler:IsSyncedCode() then return end


local transferUnit = Spring.TransferUnit

 

function gadget:GameFrame(n)
		if (n % (5*30) < 0.1) then  
			local allUnitsTable = Spring.GetAllUnits()
			local teamTable = Spring.GetTeamList()
			local numTeams = #teamTable
		end
		for i, unitID in ipairs(allUnitsTable) do
			--for each unit, randomly assign it to a team
			local teamTablePos = math.random(1, numTeams)
			local newTeamID = teamTable[teamTablePos]
			transferUnit(unitID, newTeamID)
		end
	end